package com.cmii.sjw.department.control.common;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;

import java.util.Collection;

/**
 * JsonUtil
 *
 * @author yinruidong
 * @date 2019/1/29
 * @description json转换工具栏
 */
@Slf4j
public class JsonUtil {

	public static <T> String toJson(T obj) {
		return JSON.toJSONString(obj);
	}

	public static <T> T fromStr(String json, Class<T> clz) {
		return JSON.parseObject(json,clz);
	}

	public static <T> Collection<T> getCollectionFromStr(String json, Class<T> clz) {
		return JSON.parseArray(json,clz);
	}
	

}
